<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
  <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> 
  <meta name="format-detection" content="telephone=no" />
 <link href="/css/style.css" rel="stylesheet" type="text/css" />
  <link href="/css/order.css" rel="stylesheet" type="text/css" />
  <!--<link href="css/h5_02.css" rel="stylesheet" type="text/css">--> 
  <script src="/js/jquery-1.8.2.min.js"></script>
  <!--<link href="css/subOrder.css" rel="stylesheet" type="text/css" />--> 
  <script type="text/javascript">
        var memberId = "5670a4f611565719e9e9c679";
        var queryFlag = "1";

        function goBack(){
            window.location.href = 'order_list.html';
        }
        //获取选择的值
        $(document).ready(function(){
            $("#order1").hide();
            $("#order2").hide();
            $("#order3").hide();
            $("#order"+queryFlag).show();

            $("#tab1").removeClass("sel");
            $("#tab2").removeClass("sel");
            $("#tab3").removeClass("sel");
            $("#tab"+queryFlag).addClass("sel");


            $("#ul li").each(function(index){
                $(this).click(function(){
                console.log('click')
                    $(this).addClass("sel");
                    $(this).siblings().removeClass("sel");
                    queryFlag = index+1;

                });
            });
        });

        function orderIndex(index){
            $.ajax({
                url: "/order/ordersPost",
                type: "post",
                data: {
                    status: index
                },
                success: function (resp) {
                    if(resp.orderList!=null&&resp.orderList!=undefined&&resp.orderList!=''){
                        var datas='';

                        for(int = i = 0;i<resp.orderList.length;i++){
                            if(resp.orderList[i].status == 0) {
                                var btn = "<dd class='a_info'><a href= '/order/cancelOrder?id="+ resp.orderList[i].id+" ' class='btn_primary_s'>取消</a></dd></dl>"
                            }else {
                                var btn = "<dd class='a_info'><a href= '#' class='btn_primary_s'>不可取消</a></dd></dl>"

                            }
                           datas+= "<dl><div onclick='goOrderDetailPay("+ resp.orderList[i].id+");'>" +
                               "<dt><img src='/images/camera.jpg'/><p>"+resp.orderList[i].bookDayS+"</p></dt>" +
                               "<dd>"+(resp.orderList[i].bookTime==1?"9:00~11:00":"13:00~15:00")+"</dd><dd>订单号"+resp.orderList[i].id+"</dd></div>" +
                                   btn;
                        }
                        $("#ordernone").hide()
                        $("#orderhave").html(datas);
                        $("#orderhave").show();

                    }else {
                        $("#orderhave").hide();
                        $("#ordernone").show();

                    }
                },
                error: function () {

                }
            })
        }

        function goOrderDetailNoPay(orderId){
            window.location.href= "/Mdj/wxOrder/orderDetail/?memberId="+memberId+"&orderId="+orderId+"&queryFlag="+queryFlag;;
        }
        function goStarslmOrderDetailNoPay(orderId){
            window.location.href= "/Mdj/wx/starslm/orderDetail/"+memberId+"/"+orderId+"/5?queryFlag="+queryFlag;;
        }
        function goCoachOneVsOne(orderId){
//            window.location.href= "/Mdj/wx/course/orderDetail/"+memberId+"/"+orderId+"?queryFlag="+queryFlag;;
            window.location.href = "/Mdj/pay/"+tempId+"?payFlag=2&payType="+payType+"&sessionId="+sessionId;//1:生成新订单 2：未支付的重新支付 3：支付子订单
        }

        function goOrderDetailPay(orderId,status,serviceType){
            var finishUrl;
//            if(status ==  3 && (serviceType ==1/* || serviceType ==0*/)){
//                finishUrl = "/Mdj/wxOrder/orderDetail/?memberId="+memberId+"&orderId="+orderId+"&queryFlag="+queryFlag+"&extraFlag=1";;
//            }else{
//                if(serviceType == 5) {
//                    goStarslmOrderDetailNoPay(orderId);
//                    return;
//                }
////                }else if(serviceType == 7){
////                    goCoachOneVsOne(orderId);
////                    return ;
////                }
//                finishUrl = "/Mdj/wxOrder/orderDetail/?memberId="+memberId+"&orderId="+orderId+"&queryFlag="+queryFlag;
//            }
            window.location.href= '/order/detail?id=' + orderId;
        }

        function goOrderDetailWithExtra(orderId){
            var finishUrl = "/Mdj/wxOrder/orderDetail/?memberId="+memberId+"&orderId="+orderId+"&queryFlag="+queryFlag+"&extraFlag=1";
            window.location.href= finishUrl;
        }

        function finishOrder(orderId){
            var ajax=InitAjax();
            var param ="orderId="+orderId +"&t="+new Date().getTime();
            var checkUrl = "/Mdj/wxOrder/finishOrder";
            ajax.open("POST", checkUrl, true);
            ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                if (ajax.readyState == 4 && ajax.status == 200) {
                    var data=JSON.parse(ajax.responseText);
                    if(data.status == 1){  //服务完成刷新页面
//                        window.location.reload();
                        window.location.href = "/Mdj/wxOrder/serviceFinish?memberId="
                                                + memberId + "&orderNo=" + data.data;
                    }else{
                        alert(data.info);
                    }
                }
            }
            //发送参数
            ajax.send(param);
        }

        function reuseOrder(orderId){
            var ajax=InitAjax();
            var param ="orderId="+orderId +"&t="+new Date().getTime();
            var checkUrl = "/Mdj/wxOrder/reuseOrder";
            ajax.open("POST", checkUrl, true);
            ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                if (ajax.readyState == 4 && ajax.status == 200) {
                    var data=JSON.parse(ajax.responseText);
                    if(data.status == 1){  //服务完成刷新页面
                        window.location.reload();
                    }else{
                        alert(data.info);
                    }
                }
            }
            //发送参数
            ajax.send(param);
        }

        ///评论订单
        function goDiscuss(orderNo){
            window.location.href = "/Mdj/discuss/newIndex?memberId=" + memberId + "&orderNo=" + orderNo;
        }


        // 确认更改 表示客户接受美到家取消订单退款规则
        function cancelConfirm(orderId,type){
            // 关闭弹屏
            $("#confirmMsg").text("");
            $("#confirmWind").hide();

            var param = "orderId="+orderId +"&type="+type;
            var ajax=InitAjax();
            var url = "/Mdj/userRefunds/confirmCancel";
            ajax.open("POST", url, true);
            ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                if (ajax.readyState == 4 && ajax.status == 200) {
                    var data=JSON.parse(ajax.responseText);
                    var status = data.status;
                    if (status == -1){
                        showWarn(data.info);
                    }
                    window.location.reload();
                }
            }
            ajax.send(param);
        }

        // 取消订单
        function cancelOrder(orderId){
            var host = window.location.host;
            var url = "/Mdj/userRefunds/cancelOrder";
            url = "http://" + host  + url;
            var data = {
                orderId:orderId
            };
            $.ajax({
                url:url,
                type:"post",
                data:data,
                dataType:"json",
                success:function(data){
                    var status = data.status;
                    if (status == 1 || status == 2 || status == 3 || status == 19 || status == 20){
                        // 已接单订单处理
                        showConfirm(orderId,data.info);
                    } else if (status == 14){
                        // 待确认订单 直接跳转确认
                        goExamine(orderId);
                    } else {
                        showWarn(data.info);
                    }
                },
                error:function(data){
                    alert("服务器异常")
                }
            });
        }

        function showWarn(msg) {
            $("#warnMsg").text(msg);
            $("#warnWind").show();
        }
        function closeWarn() {
            $("#warnMsg").text("");
            $("#warnWind").hide();
            // 刷新当前页
            window.location.reload();
        }

        function showConfirm(orderId,msg) {
            //
            $("#confirmOk").attr("onclick","goExamine('" + orderId +"');");
            $("#confirmClose").attr("onclick","cancelConfirm('" + orderId + "',4);");

            $("#confirmMsg").text(msg);
            $("#confirmWind").show();
        }

        // 跳转审核页填写取消订单
        function goExamine(orderId){
            // 跳转 退款页
            var url = "/Mdj/wxOrder/examineDetail?memberId="+memberId+"&orderId="+orderId+"&queryFlag="+queryFlag;
            window.location.href = url;
        }


    </script> 
  <title>我的订单</title> 
  <style>
        .h_icon img{float: left;width: 12px;height: 20px;  position: absolute;  left: 0;  top: 0;  margin-top: 12px;}
    </style> 
 </head> 
 <body> 
  <!--弹屏--> 
  <div id="warnWind" style="display: none"> 
   <div class="play_screen1"> 
    <div class="play_table"> 
     <div class="play_table_title" id="warnMsg"> 
     </div> 
     <div> 
      <input type="button" value="确认" class="play_table_btn1" onclick="closeWarn();" id="closeBtn" /> 
     </div> 
    </div> 
   </div> 
   <div class="mui-dialog-mask"> 
   </div> 
  </div> 
  <!--弹屏--> 
  <!--用户确认--> 
  <div id="confirmWind" style="display: none"> 
   <div class="play_screen1"> 
    <div class="play_table"> 
     <div class="play_table_title" id="confirmMsg"> 
     </div> 
     <div style="text-align: center"> 
      <input type="button" value="我要退款" class="play_table_btn1" style="width:30%;" id="confirmOk" /> 
      <input type="button" value="取消" class="play_table_btn1" style="width:30% " id="confirmClose" /> 
     </div> 
    </div> 
   </div> 
   <div class="mui-dialog-mask"> 
   </div> 
  </div> 
  <!--弹屏-->
  <ul class="tab_02" id="ul"> 
   <li class="sel" id="tab1" onclick="orderIndex(0);">已预约</li>
   <li id="tab2" onclick="orderIndex(1);">待拍摄</li>
   <li id="tab3" onclick="orderIndex(3);">已完成</li>
  </ul> 
  <div id="main" style="padding: 15px 0; margin-bottom:50px;"> 
   <div class="order_list" id="ordernone">
    <div class="nonews">
     <p>暂时没有订单信息</p>
    </div> 
   </div>
   <div class="order_list" id="orderhave">
    <!--<dl>-->
     <!--<div onclick="goOrderDetailPay('5670a8630cf22dba031ab92e','5','1');">-->
      <!--<dt>-->
       <!--<img src="images/fd5f1ce7e50c9541c2c4ad48670f552c.jpg" alt="" />-->
       <!--&lt;!&ndash;新娘妆&ndash;&gt;-->
       <!--<p>新娘妆</p>-->
      <!--</dt>-->
      <!--<dd>-->
       <!--订单号：840692-->
      <!--</dd>-->
      <!--<dd>-->
       <!--化妆师： 周慧-->
      <!--</dd>-->
      <!--<dd>-->
       <!--化妆费： 568元-->
      <!--</dd>-->
     <!--</div>-->
     <!--<dd class="a_info">-->
      <!--<a href= "member_order_fuhuo.html" class="btn_primary_s">复活</a>-->
      <!--&lt;!&ndash;<a href="javascript:reuseOrder('5670a8630cf22dba031ab92e');" class="btn_primary_s">复活</a>&ndash;&gt;-->
     <!--</dd>-->
    <!--</dl>-->
   </div> 
  </div>
  <footer id="footer" class="foot">
   <ul>
    <li>
     <a href="/">
      <span class="img"><img src="/images/nav1.png"></span>
      <p>首页</p>
     </a>
    </li>
    <li>
     <a href="/hot/index">
      <span class="img"><img src="/images/nav2.png"></span>
      <p>动态</p>
     </a>
    </li>
    <li>
     <a href="/order/index">
      <span class="img"><img src="/images/nav3.png"></span>
      <p>预约</p>
     </a>
    </li>
    <li class="active">
     <a href="/user/index">
      <span class="img"><img src="/images/nav4.png"></span>
      <p>我的</p>
     </a>
    </li>
   </ul>
  </footer>
 </body>
 </body>
<script>
 $(function () {
     orderIndex(0)
 })
</script>
</html>